<template>
  <div id="app">
    <!--<img src="./assets/logo.png">-->
    <router-link to="/home">首页</router-link>
    <!--<router-link to="/login">登陆</router-link>-->
    <router-link to="/logout">退出登陆</router-link>
    <router-view/>
  </div>
</template>

<script>
export default {
  name: 'App',
  //组件被挂载时，会自动调用
  mounted() {
    //绑定事件
    window.addEventListener('unload', this.saveState);
  },
  methods: {
    saveState(){
      //向sessionStorage中设置一个state表示，值是从vuex空间中拿到的state
      sessionStorage.setItem('state', JSON.stringify(this.$store.state));
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
